home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 12869 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: morse.ukonline.co.uk!usenet
  2. From: g.tafuro@ukonline.co.uk
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Help me please
  5. Date: 21 Mar 1996 15:06:46 GMT
  6. Organization: UK Online
  7. Message-ID: <4irra6$g7u@morse.ukonline.co.uk>
  8. References: <9MGBMHAUirSxEwbi@waichung.demon.co.uk>
  9. NNTP-Posting-Host: wwwproxy.ukonline.co.uk
  10.  
  11. There is nothing wrong building a structure as the one you shown in the
  12. message.
  13. However that is not an object oriented way of doing that.
  14.  
  15. I would rather create a proper class (with private data members, default
  16. constructor, destructor, copy constructor, assignment operator, etc.) that
  17. would contain all the operations (functions) required.
  18.  
  19. Also I would create an abstract class (let's say TreeType) from which I
  20. would derive my BTree class. Doing this you would create your standard for
  21. declaring objects that are trees (no matter if binary or not).
  22.  
  23. If you create a BTree class then you should also create an iterator that
  24. would be able to walk the entire b-tree and return all the data contained
  25. in the b-tree.
  26. Generally, iterators are used only for browsing not to write on the object
  27. of the iteration.
  28. Your printing procedure then would be implemented using the b-tree iterator.
  29.  
  30. I am sure that you can find many examples of OO binary trees on many books
  31. on OO techniques.
  32. As you now using C++, you should try to implement your programs in an OO
  33. way.
  34.  
  35. Hope this helps.
  36.  
  37. Gabriele Tafuro
  38. g.tafuro@ukonline.co.uk
  39.